﻿using System;
using System.ComponentModel;

namespace DatabaseGroup.SSIS.SourceAdapters.View
{
    /// <summary>
    /// Defines core functionality of the Editor view relating 
    /// to the main view workings
    /// </summary>
    public interface IEditorBaseView
    {
        /// <summary>
        /// Indicates the user has clicked the OK button and desires
        /// the settings to be saved
        /// </summary>
        event CancelEventHandler SavingSettings;

        /// <summary>
        /// Indicates the user has clicked the cancel button and
        /// desires the changes to be discarded
        /// </summary>
        event EventHandler CancelSettings;

        /// <summary>
        /// Indicates that the tab is being navigated away from
        /// </summary>
        event CancelTabEventHandler LeavingTab;

        /// <summary>
        /// Indicates a tab has been selected for viewing
        /// </summary>
        event TabEventHandler ViewSettings;

        /// <summary>
        /// Displays an error message within the view
        /// </summary>
        /// <param name="message">The error message to display</param>
        void ShowErrorMessage(string message);

        /// <summary>
        /// Hides any displayed error messages
        /// </summary>
        void HideErrorMessage();

        /// <summary>
        /// Displays a messagebox to the user requesting a yes/no response
        /// </summary>
        /// <param name="message">The confirmation message to display</param>
        /// <returns>True if the user confirms (OKs) the message</returns>
        bool RequestUserConfirmation(string message);

        /// <summary>
        /// Displays a messagebox alert to the user with a single OK button
        /// </summary>
        /// <param name="message">The message to display</param>
        void ShowAlert(string message);
        
        /// <summary>
        /// Returns the settings of a tab based on the controls hosted within it
        /// </summary>
        /// <typeparam name="T">The concrete type of the ITabSettings required</typeparam>
        /// <param name="tab">The tab to retrieve the settings for</param>
        /// <returns>The ITabSettings object</returns>
        T GetTabSettings<T>(EditorViewTab tab) where T : ITabSettings;
    }
}
